package com.ruoyi.system.mapper;

import java.util.List;
import com.ruoyi.system.domain.FyProject;
import com.ruoyi.system.domain.vo.web.HomeProjectWebVo;
import com.ruoyi.system.domain.vo.web.WebProjectVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 项目Mapper接口
 *
 * @author ruoyi
 * @date 2025-06-05
 */
public interface FyProjectMapper
{
    /**
     * 查询项目
     *
     * @param projectId 项目主键
     * @return 项目
     */
    public FyProject selectFyProjectByProjectId(Long projectId);

    /**
     * 查询项目列表
     *
     * @param fyProject 项目
     * @return 项目集合
     */
    public List<FyProject> selectFyProjectList(FyProject fyProject);
    public List<FyProject> selectFyProjectList2(FyProject fyProject);

    @Select("select " +
            "project_id as projectId," +
            "project_name as projectName," +
            "project_img as projectImg," +
            "project_img as projectImg," +
            "project_brief as projectBrief from fy_project where is_top='Y' and is_delete = 0;")
    public List<HomeProjectWebVo> selectFyProjectListHome();


    @Select("<script>"+
            "select fpt.project_id as projectId,\n" +
            "fpt.project_name as projectName,\n" +
            "fpt.project_type as projectType,\n" +
            "fpt.project_level as projectLevel,\n" +
            "fpt.project_batch as projectBatch,\n" +
            "fpt.unit as unit,\n" +
            "GROUP_CONCAT(fpe.people_name SEPARATOR ', ') AS peopleName  from fy_project fpt\n" +
            "LEFT JOIN (select * from fy_people where is_delete = 0 ) fpe on  fpt.project_id=fpe.project_id\n" +
            "<where>\n" +
            "            <if test=\"projectName != null  and projectName != ''\"> and fpt.project_name like concat('%', #{projectName}, '%')</if>\n" +
            "            <if test=\"projectType != null  and projectType != ''\"> and fpt.project_type = #{projectType}</if>\n" +
            "            <if test=\"projectLevel != null  and projectLevel != ''\"> and fpt.project_level = #{projectLevel}</if>\n" +
            "            and fpt.is_delete = 0\n" +
            "        </where> GROUP BY\n" +
            "    fpt.project_id, fpt.project_name, fpt.project_type, fpt.project_level, fpt.project_batch, fpt.unit " +
            "ORDER BY \n" +
            "    CASE \n" +
            "        WHEN fpt.project_type = '民间文学' THEN 1\n" +
            "        WHEN fpt.project_type = '传统音乐' THEN 2\n" +
            "        WHEN fpt.project_type = '传统舞蹈' THEN 3\n" +
            "        WHEN fpt.project_type = '传统戏剧' THEN 4\n" +
            "        WHEN fpt.project_type = '曲艺' THEN 5\n" +
            "        WHEN fpt.project_type = '传统体育、游艺与杂技' THEN 6\n" +
            "        WHEN fpt.project_type = '传统美术' THEN 7\n" +
            "        WHEN fpt.project_type = '传统技艺' THEN 8\n" +
            "        WHEN fpt.project_type = '传统医药' THEN 9\n" +
            "        WHEN fpt.project_type = '民俗' THEN 10\n" +
            "        ELSE 11\n" +
            "    END,\n" +
            "    convert(fpt.project_name using gbk) ASC "+"</script>"
    )
    public List<WebProjectVo> selectWebProject(@Param("projectName") String projectName,
                                               @Param("projectType") String projectType,
                                               @Param("projectLevel") String projectLevel);
    /**
     * 新增项目
     *
     * @param fyProject 项目
     * @return 结果
     */
    public int insertFyProject(FyProject fyProject);

    /**
     * 修改项目
     *
     * @param fyProject 项目
     * @return 结果
     */
    public int updateFyProject(FyProject fyProject);

    /**
     * 删除项目
     *
     * @param projectId 项目主键
     * @return 结果
     */
    public int deleteFyProjectByProjectId(Long projectId);

    /**
     * 批量删除项目
     *
     * @param projectIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteFyProjectByProjectIds(Long[] projectIds);
}
